﻿<UserControl x:Class="Animator3D.Controls.AnimationSlider"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:sac="clr-namespace:SkeletalAnimation3D.Core;assembly=SkeletalAnimation3D"
    Height="auto" HorizontalAlignment="Stretch">
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*"/>
			<RowDefinition Height="auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="auto"/>
			<ColumnDefinition Width="auto"/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<ComboBox Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" ItemsSource="{Binding}" MinWidth="150" IsSynchronizedWithCurrentItem="True">
			<ComboBox.ItemTemplate>
				<DataTemplate>
					<TextBlock Text="{Binding Name}" />
				</DataTemplate>
			</ComboBox.ItemTemplate>
		</ComboBox>
		<Grid Grid.Column="1" Grid.Row="0" Height="32" Margin="4,4,0,0">
			<Grid.ColumnDefinitions>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
				<ColumnDefinition/>
			</Grid.ColumnDefinitions>
			<Button Grid.Column="0" x:Name="FirstAnimationFrameButton" Click="FirstAnimationFrameButton_Click" Style="{DynamicResource FirstButton}"/>
			<Button Grid.Column="1" x:Name="PreviousAnimationFrameButton" Click="PreviousAnimationFrameButton_Click" Style="{DynamicResource PreviousButton}" />
			<ToggleButton Grid.Column="2" x:Name="StartAnimationButton" Click="StartAnimationButton_Click"  Style="{DynamicResource PlayButton}" />
			<ToggleButton Grid.Column="3" x:Name="PauseAnimationButton" Click="PauseAnimationButton_Click"  Style="{DynamicResource PauseButton}"/>
			<Button Grid.Column="4" x:Name="StopAnimationButton" Click="StopAnimationButton_Click"  Style="{DynamicResource StopButton}"/>
			<Button Grid.Column="5" x:Name="NextAnimationFrameButton" Click="NextAnimationFrameButton_Click" Style="{DynamicResource NextButton}" />
			<Button Grid.Column="6" x:Name="LastAnimationFrameButton" Click="LastAnimationFrameButton_Click" Style="{DynamicResource LastButton}"/>
			<ToggleButton Grid.Column="7" x:Name="LoopAnimationButton"  Style="{DynamicResource LoopButton}"/>
		</Grid>
    <Grid Grid.Row="1" Grid.ColumnSpan="3">
			<Slider Panel.ZIndex="1" Grid.Row="1" Grid.Column="0" Minimum="0" Maximum="1" x:Name="timeSlider" ValueChanged="timeSlider_ValueChanged" Margin="0,24,0,0" />
			<ItemsControl Panel.ZIndex="0" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding Frames}">
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<Grid/>
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
				<ItemsControl.Template>
					<ControlTemplate TargetType="ItemsControl">
						<Grid Panel.ZIndex="0"  >
							<ItemsPresenter>
								<ItemsPresenter.Resources>
									<DataTemplate DataType="{x:Type sac:BoneFrame}">
										<Slider Value="{Binding Offset}" Minimum="0" Maximum="1" Style="{DynamicResource KeyFrameSliderStyle}"/>
									</DataTemplate>
								</ItemsPresenter.Resources>
							</ItemsPresenter>
						</Grid>
					</ControlTemplate>
				</ItemsControl.Template>
			</ItemsControl>
			
		</Grid>
	</Grid>
</UserControl>
